package cn.genmer.test.security.tencent;

import cn.genmer.test.security.common.CommonResult;
import cn.genmer.test.security.utils.HttpSendClient;

public class TencentAddressResolution {

    private static final String TENCENT_ADDRESS_RESOLUTION_URL = "https://apis.map.qq.com/ws/geocoder/v1/?";
    private static final String TENCENT_ADDRESS_KEYWORD = "smart_address=";
    private static final String TENCENT_ADDRESS_RESOLUTION_KEY = "&key=XABBZ-M4QWJ-EG4FX-FROJS-MYSEK-G2B7V";
    private static final String TENCENT_ADDRESS_RESOLUTION_PUBLIC_PARAMS = "&addition_fields=town,town_code,town_reliability,split_address";


    public static void main(String[] args) {
        System.out.println(addressAnalysis("福建省厦门市嘉庚体育馆"));
    }

    /**
     * 腾讯地图分词
     * @return
     */
    private static String addressAnalysis(String address) {
        String url = TENCENT_ADDRESS_RESOLUTION_URL + TENCENT_ADDRESS_KEYWORD + address + TENCENT_ADDRESS_RESOLUTION_KEY + TENCENT_ADDRESS_RESOLUTION_PUBLIC_PARAMS;

        CommonResult commonResult = HttpSendClient.doGet(url);
        return commonResult.getData().toString();
    }
}
